package dahua_design.model04;

import dahua_design.model02.AccessUser;
import dahua_design.model02.IUser;
import dahua_design.model02.SqlServerUser;
import dahua_design.model03.AccessDepartment;
import dahua_design.model03.IDepartment;
import dahua_design.model03.SqlServerDepartment;

/**
 * @ClassName: DataAccess
 * @Description: 简单工厂模式改进抽象工厂模式  (取代了IFactory SqlserverFactory AccessFactory三个类作用)
 * @Version: v1.0.0
 * @Author: tamir
 * @Date: 2022/06/01
 * Modification History:
 * Date             Author      Version     Description
 * -------------------------------------------------------------
 * 2022/06/01      tamir        v1.0.0      创建
 */
public class DataAccess {
	private static final String DB = "SqlServer";
	
	public static IUser createUser() {
		IUser iUser = null;
		switch (DB) {
			case "SqlServer":
				iUser = new SqlServerUser();
				break;
			case "Access":
				iUser = new AccessUser();
				break;
			default:
				iUser = new AccessUser();
		}
		return iUser;
	}
	
	public static IDepartment createDepartment() {
		IDepartment iDepartment = null;
		switch (DB) {
			case "Sqlserver":
				iDepartment = new SqlServerDepartment();
				break;
			case "Access":
				iDepartment = new AccessDepartment();
				break;
			default:
				iDepartment = new AccessDepartment();
		}
		return iDepartment;
	}
}
